package Demo;

public class ThreadDemo7 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            while(!Thread.currentThread().isInterrupted()){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                    break;
                }
                System.out.println("正在工作中");
            }
            System.out.println("工作结束");
        });
        t1.start();
        Thread.sleep(3000);
        System.out.println("让t1线程结束");
        t1.interrupt();
    }
}
